/************************************************************************************************************************************
 *File     : multiTex.ps
 *Author   : cpzhang<chengpengzhang@gmail.com>
 *Date     : 2010-4-22
 *Platform : Windows XP, 32-bit, MSVC++ 2005, NVIDIA GeForce 9500 GT, 512M
 *Desc     : Pixel Shader that does multi-Texturing
***********************************************************************************************************************************/

/* global variables */
sampler baseTex;
sampler spotLightTex;
sampler textTex;
float   time;

/* input structure */
struct VS_INPUT
{
	vector<float, 2> base      : TEXCOORD0;
	vector<float, 2> spotLight : TEXCOORD1;
	vector<float, 2> text      : TEXCOORD2;
};

/* output structure */
struct VS_OUTPUT
{
	vector<float, 4> diffuse  : COLOR0;
};

/* main entry point */
VS_OUTPUT main(VS_INPUT input)
{
	/* zero out output */
	VS_OUTPUT output = (VS_OUTPUT)0;

	/* sample textures */
	vector<float, 4> b = tex2D(baseTex, input.base);
	vector<float, 4> s = tex2D(spotLightTex, input.spotLight);
	vector<float, 4> t = tex2D(textTex, input.text);

	/* combine texel colors */
	vector<float, 4> c = b * t + s;

	/* increase the intensity */
	c += sin(time) * 0.1;
	
	/* save the resulting pixel color */
	output.diffuse = c;
	
	/* return */
	return output;
}
 
